package com.panghl.service;


import com.panghl.config.redis.RedisCache;
import com.panghl.entity.User;
import com.panghl.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService {
    @Resource
    private UserMapper userMapper;

    @Resource
    private RedisCache redisCache;

    public User getById(int id) {
        User user = null;
        user = (User)redisCache.getCacheObject("user:" + id);
        if (null==user){
            user = userMapper.selectById(id);
            redisCache.setCacheObject("user:"+id,user);
        }
        return user;
    }



}
